/*
 * @Descripttion: 
 * @version: 
 * @Author: ada.wu
 * @Date: 2024-04-09 19:53:43
 * @LastEditors: ada.wu
 * @LastEditTime: 2024-04-09 19:55:18
 */
/*
 * Author: ada.wu
 * Date: 2020-11-18 09:49:06
 * LIBERTYONE-8407 RSA加密
 * 开发参考网址:  https://juejin.im/post/6844903749626888200
 * 秘钥生成网址： http://www.metools.info/code/c80.html
 * 密钥长度：2048bit
 * 密钥格式:PKCS#8
 * 私钥密码：无
 */
//这里是公钥 用加解密
export const RSA_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArZsL6UiZ0UE/CktpJiEe
BC+cIuMkufJH4cTaIj24yH471fiFZFFOHkzHn1ZQnSEYEvYF6linXlq+3JTOAAg8
Sqx7PoMiDpdyiyFQuVZiWkm+4LuMqWUEt1rQsb43ZN8M6SF8Iayjygc6596le7fK
+HttoTIBY2OszHRtMvutscwop27TGmXOnI9uAPl5ovHmRqrik3jWAnKn809qf0rD
ZCeW3YvzhxtvfNMXC/vn+BQH6GTYK1YrGNEsOHmyYUYCoi/XoYVU4e8X4oQs+adP
InVOPOXAlwK0CJ6a5nwOtycGGaehsdMJkz/7NLPaPo8q4vTBX2+E3GCahxMF0QCI
zQIDAQAB
-----END PUBLIC KEY-----
`
//这里是私钥 用于解密
export const RSA_PRIVATE_KEY = `-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCtmwvpSJnRQT8K
S2kmIR4EL5wi4yS58kfhxNoiPbjIfjvV+IVkUU4eTMefVlCdIRgS9gXqWKdeWr7c
lM4ACDxKrHs+gyIOl3KLIVC5VmJaSb7gu4ypZQS3WtCxvjdk3wzpIXwhrKPKBzrn
3qV7t8r4e22hMgFjY6zMdG0y+62xzCinbtMaZc6cj24A+Xmi8eZGquKTeNYCcqfz
T2p/SsNkJ5bdi/OHG2980xcL++f4FAfo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Cwib8x+q3nCR+0D1fdhnJOHJ2R1QLElRJoIMsgdEoKIYCm7J6GfJY9HZr9fw
bMHb6FaHL+N4XI1rNaZr4qdTIo5m/ku+qKqrhLUCgYA8XnFdnMD9Zy9SfrE3PI1R
kbTYAfkLYMHO8aksaViUI5nrq5RWlas2NCLseFoOYv/uJLfYqgA8iajwicwEIZhA
nVdMFrQBb/f3fePGTLQp6XoaSRyzeKFpKWZ66PZeY6VzqQ/y+FON1p3l39mnTuwC
lsfyk9EuZcjOGV+WK9fANQ==
-----END PRIVATE KEY-----
`


import {
    JSEncrypt
} from 'jsencrypt'


/**
  * ada.wu 2020-11-18
  * rsa 加密方法
  * @param {*} pas  明文字符
  */export function RSAencrypt(pas: any) {
    //实例化jsEncrypt对象
    let jse = new JSEncrypt();
    //设置公钥
    jse.setPublicKey(RSA_PUBLIC_KEY);
    return jse.encrypt(pas);
}

/**
* ada.wu 2020-11-18
* rsa 解密方法
* @param {*} pas  加密后的字符
*/
export function RSAdecrypt(pas: any) {
    let jse = new JSEncrypt();
    // 私钥
    jse.setPrivateKey(RSA_PRIVATE_KEY)
    return jse.decrypt(pas);
}
